<?php
/*
	我的下线
*/
defined('BY_JYA') or exit('error');
$_RQ['op']=$_RQ['op']?$_RQ['op']:'main';
cfc('core')->checklogin();
if($_RQ['op']=='main'){
	$return['setting']=plugin('jy_commission')->plugin_setting('page_setting');
	$levels=array();
	$agent_ids=$_SESSION['uid'];
	$allagentnum=pdo_getall('jy_commission_member',array('team_mid'=>$_SESSION['uid']),array('mid'),'mid');
	$return['allagentnum']=count($allagentnum);
	$return['member']=pdo_get('jy_commission_member',array('mid'=>$_SESSION['uid']));
	$return['params']=array('page'=>1,'level'=>1);
	$return['psize']=20;
	$return['list']=array();
	set_html('title',$return['setting']['tmydown']?:'我的下线');
	exi($return);
}
if($_RQ['op']=='list'){
	$params=array('uniacid'=>$_SESSION['uniacid'],'team_mid'=>$_SESSION['uid']);
	$psize=20;
	$pindex=intval($_RQ['page'])?:1;
	$parameter=array(
		'params'=>$params,
		'limit'=>array($pindex,$psize),
		'orderby'=>'mid desc',
	);
	$list=pdo_getlist('jy_commission_member',$parameter);
	if(!$list){
		exi('none');
	}
	foreach($list as &$item){
		$item['member']=cfc('core')->member_show($item['mid']);
		if(!$item['member']['id']){
			pdo_delete('jy_commission_member',array('mid'=>$item['mid'],'uniacid'=>$_SESSION['uniacid']));	
		}
		$item['agenttime']=date('Y-m-d H:i:s',$item['agenttime']);
		$item['createtime']=date('Y-m-d H:i:s',$item['createtime']);
		$item['member_num']=$this->count('member',array('team_mid'=>$item['mid']),array('mid'),'mid');
	}
	exi($list);
}
?>